unit syssetup;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ModalForm, StdCtrls, Menus, MoveImageButton, LabelButton,
  ComCtrls, ToolWin, ExtCtrls;

type
  TSysSetupForm = class(TMyModalForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    edtCharge: TEdit;
    edtMinTime: TEdit;
    edtAutoHide: TEdit;
    edtAutoSave: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure MIBtnOKClick(Sender: TObject);
    procedure edtChargeKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SysSetupForm: TSysSetupForm;

implementation

uses data;

{$R *.dfm}

procedure TSysSetupForm.FormCreate(Sender: TObject);
begin
  inherited;
  edtCharge.Text:=IntToStr(DM.SysSetup.FCharge);
  edtMinTime.Text :=IntToStr(DM.SysSetup.FMinTime);
  edtAutoHide.Text :=IntToStr(DM.SysSetup.FAutoHide);
  edtAutoSave.Text :=IntToStr(DM.SysSetup.FAutoSave);
end;

procedure TSysSetupForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=caFree;
end;

procedure TSysSetupForm.MIBtnOKClick(Sender: TObject);
var
  Temp:TSysSetup;
begin
  inherited;
  try
    with Temp do
    begin
      FCharge :=StrToInt(edtCharge.Text);
      FMinTime :=StrToInt(edtMinTime.Text);
      FAutoHide :=StrToInt(edtAutoHide.Text);
      FAutoSave :=StrToInt(edtAutoSave.Text);
      DM.SysSetup.FCharge :=FCharge;
      DM.SysSetup.FMinTime :=FMinTime;
      DM.SysSetup.FAutoHide :=FAutoHide;
      DM.SysSetup.FAutoSave :=FAutoSave;
    end;
  finally
    DM.EditSysSetup(DM.SysSetup);
    ModalResult:=mrOK;
  end;
end;

procedure TSysSetupForm.edtChargeKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
    if not(Key in ['0'..'9',#8,#13]) then
    begin
      Key:=#0;
      Beep;
    end;
end;

end.
